﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UFIDA.U8.DB;

namespace UFIDA.U8C.AnLianDB.DAL
{
     

        /// <summary>
        /// 数据访问类:cust_trans_work
        /// </summary>
        public partial class DAL_cust_trans_work
        {
            public DAL_cust_trans_work()
            { }
            #region  BasicMethod

            /// <summary>
            /// 得到一个对象实体
            /// </summary>
            public List<cust_trans_work> GetModel(int iyear, int imonth, string corp ,string connstr)
            {
                List<cust_trans_work> mlist = new List<cust_trans_work>();
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select iyear,imonth,citemcode,ccode,transAmount from custwork_trans_work ");
                strSql.Append(" where iyear=@iyear and imonth=@imonth and corp = @corp ");
                SqlParameter[] parameters = {
					new SqlParameter("@iyear", SqlDbType.Int,4),
					new SqlParameter("@imonth", SqlDbType.Int,4),
                    new SqlParameter("@corp", SqlDbType.VarChar,20)
                                            };
                parameters[0].Value = iyear;
                parameters[1].Value = imonth;
                parameters[2].Value = corp;
                 
                DataSet ds = DbHelperSQL.Query(strSql.ToString(), connstr, parameters);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow item in ds.Tables[0].Rows)
                    {
                        mlist.Add(DataRowToModel(item));
                    }
                    return mlist;
                }
                else
                {
                    return null;
                }
            }


            /// <summary>
            /// 得到一个对象实体
            /// </summary>
            public cust_trans_work DataRowToModel(DataRow row)
            {
                cust_trans_work model = new cust_trans_work();
                if (row != null)
                {
                    if (row["iyear"] != null && row["iyear"].ToString() != "")
                    {
                        model.iyear = int.Parse(row["iyear"].ToString());
                    }
                    if (row["imonth"] != null && row["imonth"].ToString() != "")
                    {
                        model.imonth = int.Parse(row["imonth"].ToString());
                    }
                    if (row["citemcode"] != null)
                    {
                        model.citemcode = row["citemcode"].ToString();
                    }
                    if (row["ccode"] != null)
                    {
                        model.ccode = row["ccode"].ToString();
                    }
                    if (row["transAmount"] != null && row["transAmount"].ToString() != "")
                    {
                        model.transAmount = decimal.Parse(row["transAmount"].ToString());
                    }
                }
                return model;
            }

            #endregion  BasicMethod
            #region  ExtensionMethod

            #endregion  ExtensionMethod
        }

        public partial class cust_trans_work
        {
            public cust_trans_work()
            { }
            #region Model
            private int _iyear;
            private int _imonth;
            private string _citemcode;
            private string _ccode;
            private decimal _transamount;
            /// <summary>
            /// 
            /// </summary>
            public int iyear
            {
                set { _iyear = value; }
                get { return _iyear; }
            }
            /// <summary>
            /// 
            /// </summary>
            public int imonth
            {
                set { _imonth = value; }
                get { return _imonth; }
            }
            /// <summary>
            /// 
            /// </summary>
            public string citemcode
            {
                set { _citemcode = value; }
                get { return _citemcode; }
            }
            /// <summary>
            /// 
            /// </summary>
            public string ccode
            {
                set { _ccode = value; }
                get { return _ccode; }
            }
            /// <summary>
            /// 
            /// </summary>
            public decimal transAmount
            {
                set { _transamount = value; }
                get { return _transamount; }
            }
            #endregion Model

        } 
}
